package com.automannn.springPractice.zStudy;

import org.springframework.beans.SimpleTypeConverter;
import org.springframework.core.convert.support.DefaultConversionService;

/**
 * typeconverter使用
 * @author weave
 * @since 2024-06-18 16:03
 */
public class TypeConverterStudyTest {
    public static void main(String[] args) {
        SimpleTypeConverter typeConverter = new SimpleTypeConverter();

        //设置ConversionService
        typeConverter.setConversionService(DefaultConversionService.getSharedInstance());

        //将字符串"true"转换成Boolean类型的true
        Boolean b = typeConverter.convertIfNecessary("true", Boolean.class);
        System.out.println("b = " + b);
    }
}
